#include <isa.h>
#include "local-include/reg.h"

const char *regs[] = {
  "$0", "ra", "sp", "gp", "tp", "t0", "t1", "t2",
  "s0", "s1", "a0", "a1", "a2", "a3", "a4", "a5",
  "a6", "a7", "s2", "s3", "s4", "s5", "s6", "s7",
  "s8", "s9", "s10", "s11", "t3", "t4", "t5", "t6"
};

void isa_reg_display() {
  for(int i = 0; i<32 ; i++)
    printf("%s \tHEX:0x%016lx \tDEC:%ld\n",regs[i],gpr(i), gpr(i));
}


word_t isa_reg_str2val(const char *s, bool *success) {
  int i;
  word_t temp = 0;
  //printf("reg=%s\n",s);
  for(i=0;i<32;i++){
    //printf("reg[%d]=%s\n",i,regs[i]);
    //printf("%s = %d\n",regs[i], *regs[i]);
    if(strcmp(regs[i],s) == 0){
      *success=true;
      //printf("i=%d\n",i);
      //printf("gpr(i)=%ld\n",gpr(i));
      temp = gpr(i);
    }
  }
  //printf("temp=%ld\n",temp);
  return temp;
}
/*
word_t isa_reg_str2val(const char *s, bool *success) {

  return 0;
}*/
